import React, { Component } from 'react';
import PropTypes from 'prop-types'
import { parseRePoint, drawEvent } from './tempChart'


class SvgCenter extends Component {
    constructor(props) {
        super(props);
        this.state = {
            curDate: this.props.curDate,
            data: this.props.data
        };
    }

    componentWillReceiveProps(nextProps, nextState) {
        if (nextProps.curDate !== nextState.curDate || nextProps.data !== nextState.data) {
            this.setState({
                curDate: nextProps.curDate,
                data: nextProps.data
            })
        }
    }

    //设置props值类型
    static propTypes = {
        curDate: PropTypes.string.isRequired,
        data: PropTypes.object,
    }

    //初始化默认值
    static defaultProps = {
        curDate: '',
        data: {},
    }


    render() {
        let { curDate, data = {} } = this.state;

        return (
            <svg id="svgCenterId">
                {
                    drawEvent(data.eventDatas, curDate).map((v, i) => {
                        return v;
                    })
                }

                {
                    parseRePoint(data, curDate).map((v, i) => {
                        //绘制点
                        return v;
                    })
                }

                {/* {tw_mouth(ow_p, '口温：160')} */}

                {/* {tw_axillary(yw_p, '腋温：42')}

                {tw_forehead(ow_p, '额温：41')} */}


            </svg>
        )
    }
}

export default SvgCenter;